<template>
  <div id="app">
    <div v-title data-title='注册'></div>
    <div class="container">
      <div class="close">
        <span class="iconfont iconicon-test"></span>
      </div>
      <div class="logo">
        <span class="iconfont iconnew"></span>
      </div>
      <div class="inputs">
        <myinput
          v-model="user.username"
          placeholder="请输入手机号"
          :rules="/^1[356789]\d{9}$/"
          message="请输入11位手机号码"
        ></myinput>
        <myinput
          v-model="user.nickname"
          placeholder="请输入名称"
        ></myinput>
        <myinput
          v-model="user.password"
          placeholder="请输入密码"
        ></myinput>
      </div>
      <p class="tips">
        有账号？
        <a href="#/login" class="">去登录</a>
      </p>
     
      <mybutton @click="register" type="success">注册</mybutton>
    </div>
  </div>
</template>

<script>
import mybutton from "@/components/mybutton";
import myinput from "@/components/myinput";
import { userRegister} from '@/apis/user'
export default {

    data () {
        return {
            user:{
            username:'',
            password:'',
            nickname:''    
            }
        }
    },
    components:{
        myinput,mybutton
    },
    methods:{
        register(){
            userRegister(this.user)
            .then(res =>{
                // console.log(res);
                if(res.data.message == '注册成功'){
                    this.$toast.success('注册成功');
                    this.$router.push({name:'login'})
                }else{
                    this.$toast.fail(res.data.message);
                }
            })
        }
    }
};
</script>

<style lang="less" scoped>
.container {
  padding: 20px;
}
.close {
  span {
    font-size: 27 / 360 * 100vw;
  }
}
.logo {
  display: flex;
  justify-content: center;

  span {
    display: block;
    font-size: 126 / 360 * 100vw;
    // color: #d81e06;
    color: #00f5f5;
  }
}
.inputs {
  input {
    margin-bottom: 20px;
    
  }
}
.tips {
  text-align: right;
  margin-bottom: 20px;
  a {
    // color: #3385ff;
    color: rgb(255, 145, 0);
  }
}
</style>